<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>已卖出商品</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
</head>
<style type="text/css">
    body {
        font-size: 14px;
    }

    .aui-content-padded {
        margin: 0 10px;
        padding: 10px 0;
    }

    .addFriend.aui-border:after {
        border-color: #327afa;
    }

    .orderList {
        margin-bottom: 15px;
    }

    .proTitle {
        font-size: 14px;
        line-height: 17px;
        color: #666;
    }

    .proTitleP {
        margin: 8px 0 !important;
        color: #000;
    }

    .proList.aui-list-view .aui-img-object {
        max-width: 70px;
        height: 70px;
        line-height: 70px;
    }

    .orderTitle {
        font-size: 14px;
        padding: 0 12px;
        background: #fff;
        height:42px;
        line-height: 42px;
    }

    .proPrice {
        text-align: right;
        margin-top: 5px;
    }

    .proList.aui-list-view {
        margin: 0;
    }

    .aui-list-view:after {
        border: none;
    }

    .totalPrice {
        font-size: 18px;
    }

    .proFooter .aui-list-view-cell {
        text-align: right;
    }

    .proMoreHandle {
        overflow: inherit;
        height: 55px;
        padding-right: 1px;
    }

    .proMoreHandle span {
        float: right;
        display: block;
        padding: 5px 8px;
        border-radius: 3px;
        margin-right: 8px;
    }

    .proMoreHandle span.active.aui-border:after {
        border-color: #327afa;
    }

    .proMoreHandle .aui-border:after {
        border-radius: 5px;
    }

    .more {
        position: relative;
        /*margin-right: 0 !important;*/
    }

    .more a {
        /*color: #000;*/
        color: #666;
        font-size: 13px;
    }

    .moreList {
        /*left: -28px;*/
        background: #FFF;
        border-radius: 5px;

    }

    .moreList li {
        padding: 5px 8px;
        width: 100px;
        text-align: center;
    }

    .mui-popover {
        width: 100px;
    }
    .grayColor{
        color: #aaa;
    }
</style>
<body>
<div class="kongshuju">
    <p>暂无数据</p>
</div>
<div class="contain orderLists" id="orderLIst-content">
    <!-- 等待买家付款 -->
    <!--<div class="orderList">
        <div class="orderTitle myBorder">
            <span class="comName">苏州市素絮服饰有限公司</span>
            <span class="orderStatus zfBlue aui-pull-right">等待买家付款</span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell">
                    共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                </li>
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border">联系买家</span>
                </li>
            </ul>
        </div>
    </div>-->
    <!-- 买家已付款 -->
    <!--<div class="orderList">
        <div class="orderTitle myBorder">
            <span class="comName">苏州市素絮服饰有限公司</span>
            <span class="orderStatus zfBlue aui-pull-right">买家已付款</span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell">
                    共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                </li>
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="active aui-border">确认发货</span>
                    <span class="aui-border">联系买家</span>
                </li>
            </ul>
        </div>
    </div>-->
    <!-- 卖家已发货 -->
    <!--<div class="orderList">
        <div class="orderTitle myBorder">
            <span class="comName">苏州市素絮服饰有限公司</span>
            <span class="orderStatus zfBlue aui-pull-right">卖家已发货</span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell">
                    共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                </li>
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border">查看物流</span>
                    <span class="aui-border">联系买家</span>
                    &lt;!&ndash; <span>更多</span> &ndash;&gt;
                </li>
            </ul>
        </div>
    </div>-->
    <!-- 交易成功 -->
    <!--<div class="orderList">
        <div class="orderTitle myBorder">
            <span class="comName">苏州市素絮服饰有限公司</span>
            <span class="orderStatus zfBlue aui-pull-right">交易成功</span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>
                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell">
                    共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                </li>
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border active">评价</span>
                    <span class="aui-border">查看物流</span>
                       <span class="more">
                            &lt;!&ndash; 这个a锚点链接对应下面的id ，后面可以加上订单的id&ndash;&gt;
                            <a href="#bottomPopover">更多</a>
                       </span>
                </li>
            </ul>
            &lt;!&ndash; 这个id对应上面的a锚点链接 ，后面可以加上订单的id&ndash;&gt;
            <div id="bottomPopover" class="mui-popover mui-popover-bottom ">
                <div class="mui-popover-arrow"></div>
                <ul class="moreList aui-border">
                    <li tapmode onclick="hidePopover()">删除订单1</li>
                    <li tapmode onclick="hidePopover()">删除订单</li>
                </ul>
            </div>
        </div>
    </div>-->
    <!-- 交易关闭 -->
    <!--<div class="orderList">
        <div class="orderTitle myBorder">
            <span class="comName">苏州市素絮服饰有限公司</span>
            <span class="orderStatus zfBlue aui-pull-right">交易关闭</span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                    <span class="proColor">藏青</span>
                    <span class="proSize">均码</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥53.60</span>

                    <p>x1</p>
                </div>
            </li>
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell">
                    共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                </li>
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border">联系买家</span>
                    <span class="aui-border">删除订单</span>
                       <span class="more">
                            &lt;!&ndash; 这个a锚点链接对应下面的id，后面可以加上订单的id &ndash;&gt;
                            <a href="#bottomPopover1">更多</a>
                       </span>
                </li>
            </ul>
            &lt;!&ndash; 这个id对应上面的a锚点链接 &ndash;&gt;
            <div id="bottomPopover1" class="mui-popover mui-popover-bottom ">
                <div class="mui-popover-arrow"></div>
                <ul class="moreList aui-border">
                    <li tapmode onclick="hidePopover()">删除订单12</li>
                    <li tapmode onclick="hidePopover()">删除订单</li>
                </ul>
            </div>
        </div>
    </div>-->
</div>
<script id="orderList-template" type="text/x-dot-template">
    {{ for (var i in it) { }}
    <div class="orderList">
        <div class="orderTitle myBorder">
            <span class="comName"></span>
            <span class="orderStatus grayColor aui-pull-right">
                {{? it[i].status == 0}}交易关闭
                {{?? it[i].status == 1}}等待买家付款
                {{?? it[i].status == 2}}<span class="zfBlue">买家已付款</span>
                {{?? it[i].status == 3}}<span class="zfBlue">卖家已发货</span>
                {{?? it[i].status == 4}}交易成功
                {{?? it[i].status == 5}}已评价
                {{?? it[i].status == 6}}<span class="aui-text-danger">申请退款</span>
                {{?? it[i].status == 7}}<span class="aui-text-danger">申请退货</span>
                {{?}}
            </span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openOrderInfo({{=it[i].order_id}})">
            {{ for (var is in it[i].goods) { }}
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="{{=it[i].goods[is].thumb}}">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">{{=it[i].goods[is].title}}</p>
                    <span class="proColor">{{=it[i].goods[is].note}}</span>
                    <!--<span class="proSize">均码</span>-->
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥{{=it[i].goods[is].amount}}</span>

                    <p>x{{=it[i].goods[is].number}}</p>
                </div>
            </li>
            {{ } }}
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell" style="color:#666;font-size: 13px;">
                    共{{=it[i].order_number}}件 总金额：(含运费 ￥{{=it[i].fee}}) &nbsp;<span class="totalPrice aui-text-danger">￥{{=it[i].order_amount}}</span>
                </li>
                <!--未付款-->
                {{? it[i].status == 1}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border" tapmode onclick="goToChat({{=it[i].buyer}},'')">联系买家</span>
                </li>
                <!--已付款-->
                {{?? it[i].status == 2}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="active aui-border" orderId="{{=it[i].order_id}}" tapmode onclick="sureSend(this)">确认发货</span>
                    <span class="aui-border" tapmode onclick="goToChat({{=it[i].buyer}},'')">联系买家</span>
                </li>
                <!--已发货-->
                {{?? it[i].status == 3}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border" tapmode onclick="openWuLiu('{{=it[i].send_no}}')">查看物流</span>
                    <span class="aui-border"><a  tapmode onclick="goToChat({{=it[i].buyer}},'')">联系买家</a></span>
                    <!-- <span>更多</span> -->
                </li>
                <!--交易成功-->
                {{?? it[i].status == 4}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border active">评价</span>
                    <span class="aui-border" tapmode onclick="openWuLiu('{{=it[i].send_no}}')">查看物流</span>
                    <span class="more">
                            <!-- 这个a锚点链接对应下面的id ，后面可以加上订单的id-->
                        <!--<a href="#bottomPopover">更多</a>-->
                       </span>
                </li>
                <!--交易关闭-->
                {{?? it[i].status == 0}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border" tapmode onclick="goToChat({{=it[i].buyer_mobile}},'')">联系买家</span>
                    <!--<span class="aui-border" onclick="deleteOrder({{=it[i].order_id}})">删除订单</span>-->
                </li>
                {{?}}
            </ul>
        </div>
    </div>
    {{ } }}
</script>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/jquery-1.11.3.js"></script>
<script type="text/javascript" src="../../script/mui.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript">
    var page = 1, isLock = false, status = 0,frameWidth;
    apiready = function () {
        myAvatar = $api.getStorage('avatar');
        targetId = api.pageParam.targetId;
        targetAvatar = api.pageParam.targetAvatar;
        targetNickname = api.pageParam.targetNickname;
        api.parseTapmode();
        frameWidth=$("body").width();
        if (api.pageParam.status) {
            status = api.pageParam.status;
        }

        //重新加载缓存
        getStorageAll();
        //接收监听
        api.addEventListener({
            name: 'orderStatus'
        }, function (ret) {
            if (ret && ret.value) {
                page = 1;
                isLock=false;
                $("#orderLIst-content").empty();
                status = ret.value.status
                api.refreshHeaderLoading();
                return false;
            }
        });
        api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/ptr_pull.png',
            bgColor: '#efeff4',
            textColor: '#959595',
            textDown: '下拉刷新',
            textUp: '松开刷新',
            showTime: true
        }, function (ret, err) {
            isLock=false;
            page = 1;
            orderList(status);
        });
        api.refreshHeaderLoading();
        
        //监听是否达到底部上拉加载
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (!isLock)orderList(status,page);
        })

        //接收订单详情页的用户删除订单等操作更新订单数量
        api.addEventListener({
            name: 'updateOrderNum'
        }, function (ret) {
            if (ret && ret.value) {
                isLock = false;
                api.refreshHeaderLoading();
            }
        });
    }
    function openWuLiu(orderId) {
//        window.localhost.href='http://m.kuaidi100.com/result.jsp?nu='+orderId
        api.openWin({
            name: 'wuliuInfo_win',
            url: 'wuliuInfo_win.html',
            pageParam: {
                orderId: orderId
            },
            //delay: 300
        });
    }
    //订单列表
    function orderList(status,toPage) {
        if(isLock)return;

        toPage=toPage?toPage:page;
        if(toPage==1)api.refreshHeaderLoading();


        data = {
            status: status,
            userName: user_name,
            page: toPage,
        };
        url = "User/orderListSupplier";
        isLock = true;
        ajaxRequest(url, 'post', data, function (ret, err) {
            api.refreshHeaderLoadDone();
            isLock = false;
            if (ret.status == 1) {
                var content = $api.byId('orderLIst-content');
                var tpl = $api.byId('orderList-template').text;
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    if(!$.trim(ret.msg)){
                        isLock=true;
                        return;
                    }
                    $api.append(content, tempFn(ret.msg));
                } else {
                    $api.html(content, tempFn(ret.msg));
                }
            } else {
                if (page == 1) {
                    $(".kongshuju").show();
                    $("#orderLIst-content").empty();
                }
                api.toast({
                    msg: '已经加载完',
                    duration: 2000,
                    location: 'bottom'
                });
                isLock = true;
            }
        });
        hideLoading();
    }

    function openOrderInfo(orderId) {
        api.openFrame({
            name: 'orderInfoBySeller',
            url: 'orderInfoBySeller.html',

            rect : {
                x : 0,
                y : 0,
                w : 'auto',
                h : 'auto'
            },
            pageParam: {
                orderId: orderId
            },
            vScrollBarEnabled : false,
            hScrollBarEnabled : false
            //delay: 300
        });

    }

    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    function hidePopover() {
        mui('.mui-popover').popover('hide');
    }
    $(document).on("touchstart", "body", function () {
        mui('.mui-popover').popover('hide');
    })
    //确认发货
    function sureSend(obj) {
        var orderId=$(obj).attr("orderId");
        api.openFrame({
            bgColor : 'rgba(0,0,0,0.3)',
            name:"popupInputPage",
            url:"../popupInputPage_frm.html",
            bounces : false,
            rect : {
                x : 0,
                y : 0,
                w : api.frameWidth,
                h : 'auto'
            },
            softInputMode:"resize",
            pageParam:{
                orderId:orderId,
                pageType:"sendProduct"
            }
        });
    }
</script>
</html>